/*
 * RTP packet
 */

 #ifndef PACKET_H
 #define PACKET_H

#if defined(WIN32)
#include <opencv/cv.h>
#include <opencv/highgui.h>
#else
#include <cv.h>
#include <highgui.h>
#endif

#include <stdlib.h>    // for malloc
#include <stdio.h>     // for printf

#define HEIGHT 30       // height of thumbnail
#define WIDTH 53        // width of thumbnail

#define INTERVAL_MS 40  // packet timestamp interval in ms
#define VERSION 2       // RTP protocol version
#define JPEG 26

typedef struct{
	unsigned int prefix;
	unsigned int attrs;
	unsigned int timestamp;
	unsigned int ssrc;
	unsigned char* payload;
} rtp_packet;

typedef struct{
	IplImage *image;
	CvMat *thumb;
	CvMat *encoded;
	CvCapture *video;
} video_manager;

void set_buffer(unsigned char* to, unsigned char* from, unsigned long bytes);
void set_buffer_to(unsigned char* to, unsigned char from, unsigned long bytes);
//void init_packet(rtp_packet* packet, video_manager* cv, unsigned int frame_num, unsigned int seq_num);
unsigned char* get_rtp_packet(video_manager* cv, unsigned int frame_num, unsigned int seq_num);
int init_video_manager(video_manager* cv, char* filename);
int get_frame(video_manager* cv, int frame_num);
void close_video(video_manager* cv);

 #endif
